/**
 * <p>Title: SystemSettingCE.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-3-5 下午04:45:39  张志芳  Create
 *</pre>
 */
package com.baosight.sczx.common.zm.cInterface.cs;

import java.util.HashMap;
import java.util.List;

import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.cInterface.CmesConstants;
import com.baosight.sczx.zm.cs.domain.ZMCSSystemSettingCE;

/**
 * 系统设置-设备维护管理
 * <p>Title: SystemSettingCE.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-3-5 下午04:45:39  张志芳  Create
 *</pre>
 */
public class SystemSettingCE {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	private static SystemSettingCE instance = new SystemSettingCE();
	private static ZMCSSystemSettingCE systemSetting;
	
	private SystemSettingCE(){
		initData();//当第一次使用的时候初始化
	}
	
	@SuppressWarnings("unchecked")
	private void initData(){
		List<ZMCSSystemSettingCE> _list = dao.query("ZMCSSystemSettingCE.query", new HashMap<String, String>());
		if(_list.size() < 1) {
			systemSetting = null;
		}
		else {
			systemSetting = _list.get(0);
		}
		CmesConstants.EQUIMENT_CE = 0;
	}
	
	/**
	 * 设备编号中是否关联分类编号
	 * <p>Function: getIsIncludeClass</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-7-18上午02:34:01 张志芳
	 * </p>
	 *
	 */
	public boolean getIsIncludeClass(){
		String _temp = new String("1");
		if(systemSetting != null) {
			_temp = systemSetting.getFdIncludeClass();
			if(null == _temp || "".equals(_temp)) {
				_temp = new String("1");
			}
		}
		if("0".equals(_temp))
			return false;
		else
			return true;		
	}
	
	/**
	 * 设备分类的级数
	 * <p>Function: getClassLevel</p>
	 * <p>Description: </p>
	 * <p>return value:String</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午07:58:20 张志芳
	 * </p>
	 *
	 */
	public long getClassLevel(){
		long _temp = 3;//默认为 3
		if(systemSetting != null) {
			_temp = systemSetting.getFdClassLimits();
		}		
		return _temp;
	}

	
	/**
	 * 得到对象的唯一句柄
	 * <p>Function: getInstance</p>
	 * <p>Description: </p>
	 * <p>return value:SystemSettingCE</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-18下午07:50:20 张志芳
	 * </p>
	 *
	 */
	public static SystemSettingCE getInstance(){
		if(CmesConstants.EQUIMENT_CE == 1) {
			instance = new SystemSettingCE();
		}
		
		return instance;
	}
}
